package com.eco.fanliapp.controller.app;


import com.eco.fanliapp.common.base.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.service.ISyTaskTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-08-07
 */
@RestController
@RequestMapping("/app/task")
public class SyTaskTypeController extends BaseController {

    @Autowired
    private ISyTaskTypeService iSyTaskTypeService;

    /**
     * 根据任务类型查询任务列表
     * @return
     */
    @GetMapping("/type/all")
    @ResponseBody
    public ServerResponse getAppTaskAll(Integer taskType) {
        AppUser u = getAppUser();
        if(null == u) {
            return ServerResponse.createByErrorCodeMessage(301,"Token不正确");
        }
        return iSyTaskTypeService.appUserTaskAll(taskType,u.getUserId());
    }

    /**
     * 根据任务类型查询任务列表(签到)
     * @return
     */
    @GetMapping("/type/signAll")
    @ResponseBody
    public ServerResponse findAppTaskSignAll() {
        AppUser u = getAppUser();
        if(null == u) {
            return ServerResponse.createByErrorCodeMessage(301,"Token不正确");
        }
        return iSyTaskTypeService.findAppTaskSignAll(u.getUserId());
    }
}
